new Vue({
    el: '#app',
    data() {
        return {
            userid: '',
            username: '',
            password: '',
            realname: '',
            gender: '',
            rank: ''
        };
    },
    methods: {
        async register() {
            try {
                const response = await axios.post('http://10.41.152.253:8000/register/', {
                    userid: this.userid,
                    username: this.username,
                    password: this.password,
                    realname: this.realname,
                    gender: this.gender,
                    rank: this.rank
                });
                const { userid, username } = response.data;
                alert(`注册成功, 用户ID: ${userid}, 用户名: ${username}`);
                // 注册成功后跳转到登录页面
                window.location.href = './login.html';
            } catch (error) {
                console.error(error);
                this.$message.error('注册失败，请检查输入信息');
            }
        }
    }
});
